<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    #########################################################################################
    # Programmer : nawattapon yoskamtorn						    #
    # Email	: contact@nawattapon.com						    #
    # Website	: http://www.nawattapon.com						    #
    #########################################################################################
    
    class User_Model extends Initmodel
    {
        function __construct()
        {
            parent::__construct();
            $this->set_table_name('users');
        }
        
        function lists($p=1,$limit=50,$status=FALSE,$order=FALSE)
	{
	    $start = ($p-1)*$limit;
	    
	    if($status){
		$this->set_where($status); 
	    }
	    
	    if($order){
		$this->set_order_by($order); 
	    }
	    
            $this->db->select('users.* , user_group.title as group_title');
            $this->db->from('users');
            $this->db->join('user_group', 'user_group.id = users.user_group_id');
            $query = $this->db->get();
            $result = $this->fetch_data_with_desc($query);
            $this->set_free_result($query);
	    return $result;
	}
    }